import config from '@/config'
let baseImgUrl = config.baseImgUrl
const getters = {
  userInfo: state => state.user.userInfo,
  lang: state => state.app.lang,
  app: state => state.app,
  logo: state => state.logo,
  name: state => {
    if (state.app.name) {
      return state.app.name
    }
    return '涵品教育'
  },
  collapse: state => state.app.sidebar.collapse,
  activeIndex: state => state.app.sidebar.activeIndex,
  navActiveIndex: state => state.app.navbar.activeIndex,
  headerModule: state => state.app.headerModule,
  // 权限
  allAuth: state => state.user.allAuth,
  crm: state => state.user.crm,
  bi: state => state.user.bi,
  manage: state => state.user.manage,
  address: state => state.user.address,
  oa: state => state.user.oa,
  project: state => state.user.project,
  agreement: state=> state.user.agreement,
  roiManage: state => state.user.roiManage,
  preRevenueManage: state => state.user.preRevenueManage,


  // 路由
  addRouters: state => state.permission.addRouters,
  crmRouters: state => state.permission.crmRouters,
  taskExamineRouters: state => state.permission.taskExamineRouters,
  workLogRouters: state => state.permission.workLogRouters,
  addressBookRouters: state => state.permission.addressBookRouters,
  projectRouters: state => state.permission.projectRouters,
  biRouters: state => state.permission.biRouters,
  manageRouters: state => state.permission.manageRouters,
  agreementRouter: state => state.permission.agreementRouter,
  roiRouters: state => state.permission.roiRouters,
  preRevenueRouters: state => state.permission.preRevenueRouters,

  // 学员管理信息
  messageNum: state => state.crm.messageNum,
  // 配置信息
  CRMConfig: state => state.app.CRMConfig,
  imageCache: state => state.app.imageCache,
  // 背景图片信息 - start
  companyLoginImg: state => {
    if (state.init.companyLoginImg) {
      return baseImgUrl + state.init.companyLoginImg
    }
    return require('@/assets/img/admin/companyLoginImg.jpg')
  },
  companyLoginLogo: state => {
    if (state.init.companyLoginLogo) {
      return baseImgUrl + state.init.companyLoginLogo
    }
    return require('@/assets/img/admin/login-logo.png')
  },
  companyLogo: state => {
    if (state.init.companyLogo) {
      return baseImgUrl + state.init.companyLogo
    }
    return require('@/assets/img/admin/companyLogo.png')
  },
  companyName: state => {
    if (state.init.companyName) {
      return state.init.companyName
    }
    return '校企汇通CRM'
  },
  // 背景图片信息 - end

  // 初始化数据
  userAllList: state => state.crm.userAllList,
  depAllList: state => state.crm.depAllList,
  depAllTreeList: state => state.crm.depAllTreeList,

  orgExpireReminder: state => state.user.orgExpireReminder,
  showDetail: state => state.crm.showDetail,
  detailThis: state => state.crm.detailThis,
}
/**
 * 使用说明
 * import { mapGetters } from 'vuex'
 * computed: {
    ...mapGetters([
      'userInfo'
    ])
  }
 */

export default getters
